package com.jeesite.modules.billconfig.entity;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;

import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;

import java.util.Date;

/**
 * 单据配置Entity
 * @author 码脑洞
 * @version 2025-04-13
 */
@Table(name="t_bill_config", alias="a", label="单据配置信息", columns={
		@Column(name="auto_id", attrName="autoId", label="主键", isPK=true),
		@Column(name="org_id", attrName="orgId", label="组织ID", isQuery=false),
		@Column(name="org_code", attrName="orgCode", label="组织编码", isQuery=false),
		@Column(name="org_name", attrName="orgName", label="组织名称", isQuery=false),
		@Column(name="form_id", attrName="formId", label="单据类型", isUpdateForce=true),
		@Column(name="push_flag", attrName="pushFlag", label="是否推单", isQuery=false),
		@Column(name="split_barcode_rule", attrName="splitBarcodeRule", label="拆条码规则", isQuery=false),
		@Column(name="merge_barcode_rule", attrName="mergeBarcodeRule", label="合条码规则", isQuery=false),
		@Column(includeEntity=DataEntity.class),
		@Column(name="create_name", attrName="createName", label="创建人名称", isQuery=false),
		@Column(name="update_name", attrName="updateName", label="更新人名称", isQuery=false),
	}, orderBy="a.update_date DESC"
)
public class BillConfig extends DataEntity<BillConfig> {
	
	private static final long serialVersionUID = 1L;
	private Long autoId;		// 主键
	private Long orgId;		// 组织ID
	private String orgCode;		// 组织编码
	private String orgName;		// 组织名称
	private Long formId;		// 单据类型
	private String pushFlag;		// 是否推单
	private String splitBarcodeRule;		// 拆条码规则
	private String mergeBarcodeRule;		// 合条码规则
	private String createName;		// 创建人名称
	private String updateName;		// 更新人名称

	public BillConfig() {
		this(null);
	}
	
	public BillConfig(String id){
		super(id);
	}
	
	@JsonSerialize(using = ToStringSerializer.class)
	public Long getAutoId() {
		return autoId;
	}

	public void setAutoId(Long autoId) {
		this.autoId = autoId;
	}
	
	@NotNull(message="组织ID不能为空")
	public Long getOrgId() {
		return orgId;
	}

	public void setOrgId(Long orgId) {
		this.orgId = orgId;
	}
	
	@NotBlank(message="组织编码不能为空")
	@Size(min=0, max=10, message="组织编码长度不能超过 10 个字符")
	public String getOrgCode() {
		return orgCode;
	}

	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}
	
	@NotBlank(message="组织名称不能为空")
	@Size(min=0, max=30, message="组织名称长度不能超过 30 个字符")
	public String getOrgName() {
		return orgName;
	}

	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}
	
	public Long getFormId() {
		return formId;
	}

	public void setFormId(Long formId) {
		this.formId = formId;
	}
	
	@Size(min=0, max=1, message="是否推单长度不能超过 1 个字符")
	public String getPushFlag() {
		return pushFlag;
	}

	public void setPushFlag(String pushFlag) {
		this.pushFlag = pushFlag;
	}
	
	@Size(min=0, max=1, message="拆条码规则长度不能超过 1 个字符")
	public String getSplitBarcodeRule() {
		return splitBarcodeRule;
	}

	public void setSplitBarcodeRule(String splitBarcodeRule) {
		this.splitBarcodeRule = splitBarcodeRule;
	}
	
	@Size(min=0, max=1, message="合条码规则长度不能超过 1 个字符")
	public String getMergeBarcodeRule() {
		return mergeBarcodeRule;
	}

	public void setMergeBarcodeRule(String mergeBarcodeRule) {
		this.mergeBarcodeRule = mergeBarcodeRule;
	}
	
	@NotBlank(message="创建人名称不能为空")
	@Size(min=0, max=50, message="创建人名称长度不能超过 50 个字符")
	public String getCreateName() {
		return createName;
	}

	public void setCreateName(String createName) {
		this.createName = createName;
	}
	
	@NotBlank(message="更新人名称不能为空")
	@Size(min=0, max=50, message="更新人名称长度不能超过 50 个字符")
	public String getUpdateName() {
		return updateName;
	}

	public void setUpdateName(String updateName) {
		this.updateName = updateName;
	}
	
	@Override
	public Date getCreateDate_gte() {
		return sqlMap.getWhere().getValue("create_date", QueryType.GTE);
	}

	@Override
	public void setCreateDate_gte(Date createDate) {
		sqlMap.getWhere().and("create_date", QueryType.GTE, createDate);
	}

	@Override
	public Date getCreateDate_lte() {
		return sqlMap.getWhere().getValue("create_date", QueryType.LTE);
	}

	@Override
	public void setCreateDate_lte(Date createDate) {
		sqlMap.getWhere().and("create_date", QueryType.LTE, createDate);
	}
	
}